package client.screen;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

import client.MorcMIDlet;

public class MainScreen extends Screen {
	private Command exit, getFriends, sendScrap, configuration;
	
	public MainScreen(MorcMIDlet midlet, String title) {
		super(midlet, title);
		
		this.append("Bem vindo ao MobileOrkut");
	}

	protected void addCommands() {
		// Instantiate commands
		exit = new Command("Sair", Command.EXIT, 0);
		sendScrap = new Command("Recado", Command.ITEM, 2);
		getFriends = new Command("Amigos", Command.ITEM, 1);
		configuration = new Command("Configurar", Command.ITEM, 0);
		
		// Add Commands
		this.addCommand(exit);
		this.addCommand(sendScrap);
		this.addCommand(getFriends);
		this.addCommand(configuration);
	}
	
	public void commandAction(Command c, Displayable d) {
		if (c == exit) {
			try {
				this.midlet.destroyApp(true);
			} 
			catch (MIDletStateChangeException e) {
				e.printStackTrace();
			}
		}
		else if (c == sendScrap) {
			this.midlet.setScreen(MorcMIDlet.SCREEN_SCRAP);
		}
		else if (c == getFriends) {
			this.midlet.setScreen(MorcMIDlet.SCREEN_FRIENDS);
			this.midlet.getFriends();
		}
		else if (c == configuration) {
			this.midlet.setScreen(MorcMIDlet.SCREEN_CONFIGURATION);
		}
	}

}
